using System.Collections.ObjectModel;
using System.ComponentModel;
using SvgToFontConverter.Models;

namespace SvgToFontConverter.ViewModels
{
    /// <summary>
    /// 主窗口视图模型
    /// </summary>
    public class MainViewModel : INotifyPropertyChanged
    {
        private string _fontForgePath;
        private string _svgFolderPath;
        private string _outputFolderPath;
        private string _fontFamilyName;
        private bool _deleteSvgAfterConvert;
        private ConversionStep _currentStep;
        private string _statusMessage;
        private int _progressValue;
        private int _progressMaximum;
        
        public MainViewModel()
        {
            SvgFiles = new ObservableCollection<SvgFileInfo>();
            CurrentStep = ConversionStep.NotStarted;
            StatusMessage = "就绪";
            FontFamilyName = "CustomFont";
        }
        
        /// <summary>
        /// SVG文件集合
        /// </summary>
        public ObservableCollection<SvgFileInfo> SvgFiles { get; set; }
        
        /// <summary>
        /// FontForge路径
        /// </summary>
        public string FontForgePath
        {
            get => _fontForgePath;
            set
            {
                _fontForgePath = value;
                OnPropertyChanged(nameof(FontForgePath));
            }
        }
        
        /// <summary>
        /// SVG文件夹路径
        /// </summary>
        public string SvgFolderPath
        {
            get => _svgFolderPath;
            set
            {
                _svgFolderPath = value;
                OnPropertyChanged(nameof(SvgFolderPath));
            }
        }
        
        /// <summary>
        /// 输出文件夹路径
        /// </summary>
        public string OutputFolderPath
        {
            get => _outputFolderPath;
            set
            {
                _outputFolderPath = value;
                OnPropertyChanged(nameof(OutputFolderPath));
            }
        }
        
        /// <summary>
        /// 字体族名称
        /// </summary>
        public string FontFamilyName
        {
            get => _fontFamilyName;
            set
            {
                _fontFamilyName = value;
                OnPropertyChanged(nameof(FontFamilyName));
            }
        }
        
        /// <summary>
        /// 转换后是否删除SVG文件
        /// </summary>
        public bool DeleteSvgAfterConvert
        {
            get => _deleteSvgAfterConvert;
            set
            {
                _deleteSvgAfterConvert = value;
                OnPropertyChanged(nameof(DeleteSvgAfterConvert));
            }
        }
        
        /// <summary>
        /// 当前转换步骤
        /// </summary>
        public ConversionStep CurrentStep
        {
            get => _currentStep;
            set
            {
                _currentStep = value;
                OnPropertyChanged(nameof(CurrentStep));
            }
        }
        
        /// <summary>
        /// 状态消息
        /// </summary>
        public string StatusMessage
        {
            get => _statusMessage;
            set
            {
                _statusMessage = value;
                OnPropertyChanged(nameof(StatusMessage));
            }
        }
        
        /// <summary>
        /// 进度值
        /// </summary>
        public int ProgressValue
        {
            get => _progressValue;
            set
            {
                _progressValue = value;
                OnPropertyChanged(nameof(ProgressValue));
            }
        }
        
        /// <summary>
        /// 进度最大值
        /// </summary>
        public int ProgressMaximum
        {
            get => _progressMaximum;
            set
            {
                _progressMaximum = value;
                OnPropertyChanged(nameof(ProgressMaximum));
            }
        }
        
        public event PropertyChangedEventHandler PropertyChanged;
        
        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}